﻿using QFramework;
using UnityEngine;

namespace HKTools
{
    public class CMD_SetTargetFrameRate : AbstractCommand
    {
        int targetFrameRate;
        bool vSyncEnable;

        public CMD_SetTargetFrameRate(int targetFrameRate, bool vSyncEnable = true)
        {
            this.targetFrameRate = targetFrameRate;
            this.vSyncEnable = vSyncEnable;
        }

        protected override void OnExecute()
        {
            if (vSyncEnable)
            {
                QualitySettings.vSyncCount = 1;
            }
            else
            {
                QualitySettings.vSyncCount = 0;
            }

            this.GetSystem<IHK_FPSSystem>().SetTargetFrameRate(targetFrameRate);
        }
    }
}